Skip to content

Integration testing POC#687

Draft
mpeels wants to merge 12 commits intomainfrom
mp/app-332/testing-poc
Draft

Integration testing POC#687
mpeels wants to merge 12 commits intomainfrom
mp/app-332/testing-poc

Conversation

@mpeels
Copy link
Contributor

@mpeels mpeels commented Mar 11, 2026

Overview

Initial proof of concept for integration testing of RTR using TestContainers. The test added is very basic, it inserts a patient into the NBS_ODSE.Person table and verifies an entry with the appropriate ID is added to the RDB_Modern.D_PATIENT table. Future testing is expected to be much more detailed.

Docker Compose Changes

In order to have the ComposeContainer leverage the existing docker-compose.yaml, some modifications had to be made. Most notably the container_name parameter is not supported so it had to be removed from the yaml. Health checks were also added to ensure smooth and consistent container startup.

Connector Initialization and HealthChecks

For the Debezium and Kafka-connect containers to properly initialize their connector configurations, healthcheck.sh scripts were added. These scripts send a GET request to /connectors to retrieve the list of active connectors. If the expected connectors are not present, a POST request is sent to initialize them.

Known issues

The Kafka-connect container is configured to monitor topics using regex: "topics.regex": "nrt_[a-zA-Z_]+". The issue with specifying a regex is that only topics that exist at the time of connector initialization will be monitored. This causes a problem because certain topics do not exist until the post-processing-service starts. A temporary workaround is in place where the sink connector is restarted during the test execution.

Command line test execution

./gradlew post-processing-service:test --tests gov.cdc.etldatapipeline.postprocessingservice.integration.IntegrationTest

Test execution is expected to take around 4 minutes. This might be slightly longer the first time due to container builds.

JIRA

@mpeels mpeels requested a review from a team as a code owner March 11, 2026 16:34
@mpeels mpeels marked this pull request as draft March 11, 2026 17:10
@ericbuckley
Copy link
Contributor

The Kafka-connect container is configured to monitor topics using regex: "topics.regex": "nrt_[a-zA-Z_]+". The issue with specifying a regex is that only topics that exist at the time of connector initialization will be monitored. This causes a problem because certain topics do not exist until the post-processing-service starts. A temporary workaround is in place where the sink connector is restarted during the test execution.

@mpeels can we put a depends_on clause for liquibase to have completed before kafka-connect can start up?

"kafka-connect",
"person-service")
// Add specific waits to ensure connectors are ready before test execution
.waitingFor("debezium", Wait.forLogMessage(".*Starting streaming.*", 1))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the new healthchecks added to docker-compose for these waits?

@mpeels
Copy link
Contributor Author

mpeels commented Mar 11, 2026

The Kafka-connect container is configured to monitor topics using regex: "topics.regex": "nrt_[a-zA-Z_]+". The issue with specifying a regex is that only topics that exist at the time of connector initialization will be monitored. This causes a problem because certain topics do not exist until the post-processing-service starts. A temporary workaround is in place where the sink connector is restarted during the test execution.

@mpeels can we put a depends_on clause for liquibase to have completed before kafka-connect can start up?

@ericbuckley We can but that won't solve this issue. In this specific case the person-service creates the nrt_patient topic when it processes a message from the nbs_Person topic. So the topic doesn't exist until our test inserts a patient and its processed by the person-service. The Kafka sink connector never detects the new nrt_patient topic and does not start consuming messages unless it is restarted.

I believe (not tested) that if we change from the regex nrt_ to a list of specific topics to monitor, it will fix the issue. Otherwise we will need to continue to have some mechanism for restarting the connector.

@mpeels it looks like the default value for metadata.max.age.ms is 5 minutes. I believe that means it only scans for new topics every 5 mins. I wonder if we lower that in the kafka-connect container, if it will look for new topics more often?

environment:
  CONNECT_CONNECTOR_CLIENT_CONFIG_OVERRIDE_POLICY: "All"
  CONNECT_CONSUMER_METADATA_MAX_AGE_MS: 1000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants